#!/usr/bin/python3
# -*- coding:utf-8 -*-

from urllib.request import urlopen
from bs4 import  BeautifulSoup

url="http://quotes.toscrape.com/"

url_response= urlopen(url)

bs = BeautifulSoup(url_response, "html.parser")

quote_list = []
quote_list_tmp = bs.select("span.text")
for quote in quote_list_tmp:
    quote_list.append(quote.text.strip("“.”"))
#print(quote_list)

author_list = []
author_list_temp = bs.select("small.author")
for author in author_list_temp:
    author_list.append(author.text)
#print(author_list)

print("-----------------------")
tags_list = []
tags_list_temp=bs.select("div.tags")
for tags in tags_list_temp:
        a_tags_temp = tags.select("a.tag")
        a_tags = []
        for a_tag in a_tags_temp:
            a_tags.append(a_tag.text)
        tags_list.append(",".join(a_tags))
#print(tags_list)

for i in range(len(tags_list)) :
    print("\t".join([quote_list[i], author_list[i], tags_list[i] ]))



